/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simplemetrosystem.view.menu;

import javax.swing.JMenu;
import simplemetrosystem.model.charlanguage.NameMap;
import simplemetrosystem.view.MetroFrame;

/**
 * 文件菜单
 * @author Eric Qian
 */
public class FileMenu extends JMenu {

    /**
     * 
     * @param frame
     */
    public FileMenu(MetroFrame frame) {
        super();
        name = NameMap.getInstance().getName("File");
        this.setText(name);
        this.frame = frame;
        addItem();
    }
    
    /**
     * 
     */
    private void addItem() {
        add(getFileNewItem());
        add(getFileOpenItem());
        addSeparator();
        add(getFileSaveItem());
        add(getFileSaveAsItem());
        addSeparator();
        add(getFileConfigureItem());
        addSeparator();
        add(getFileExitItem());
    }

    /**
     * 
     * @return
     */
    public FileNewItem getFileNewItem() {
        if (fnItem == null) {
            fnItem = new FileNewItem(frame);
        }
        return fnItem;
    }

    /**
     * 
     * @return
     */
    public FileOpenItem getFileOpenItem() {
        if (foItem == null) {
            foItem = new FileOpenItem(frame);
        }
        return foItem;
    }

    /**
     * 
     * @return
     */
    public FileSaveItem getFileSaveItem() {
        if (fsItem == null) {
            fsItem = new FileSaveItem(frame);
        }
        return fsItem;
    }

    /**
     * 
     * @return
     */
    public FileSaveAsItem getFileSaveAsItem() {
        if (fsaItem == null) {
            fsaItem = new FileSaveAsItem(frame);
        }
        return fsaItem;
    }

    /**
     * 
     * @return
     */
    public FileConfigureItem getFileConfigureItem() {
        if (fcItem == null) {
            fcItem = new FileConfigureItem(frame);
        }
        return fcItem;
    }

    /**
     * 
     * @return
     */
    public FileExitItem getFileExitItem() {
        if (feItem == null) {
            feItem = new FileExitItem(frame);
        }
        return feItem;
    }
    private String name;
    private MetroFrame frame;
    private FileNewItem fnItem;
    private FileOpenItem foItem;
    private FileSaveItem fsItem;
    private FileSaveAsItem fsaItem;
    private FileConfigureItem fcItem;
    private FileExitItem feItem;
}
